//
//  QwarSelectView.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/2/24.
//  Copyright © 2016年 game. All rights reserved.
//

#import "QwarSelectView.h"
#import "Masonry.h"
@interface QwarSelectView ()<UITextFieldDelegate>
@property (nonatomic,strong) UIView *lin;

@end

@implementation QwarSelectView
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self CreatNameLab];
        
        
        [self CreatresultAndSelect];
        [self BottomLineCreat];
        [self CreatCount];
    }
    return self;
}

-(void)CreatNameLab{
    _name = [[UILabel alloc]init];

    _name.font = Boldfont(SCREEN_WIDTH*0.05);
    [self addSubview:_name];
    [_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.centerY.equalTo(self);
    }];
}

-(void)CreatCount{
    _count = [UILabel new];

    _count.font = Countfont(SCREEN_WIDTH*0.05);
    [self addSubview:_count];
    _count.textAlignment = NSTextAlignmentCenter;
    [_count mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-25);
        make.centerY.equalTo(self);
        make.width.equalTo(@(W(self)/4-30));
    }];
}

-(void)BottomLineCreat{
    
    [_lin removeFromSuperview];
    
    _lin = [UIView new];
    _lin.backgroundColor  = linColor;
    [self addSubview:_lin];
    [_lin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self);
        make.height.equalTo(@0.7);
    }];
}

-(void)CreatresultAndSelect{
    _result = [UITextField new];
    _result.layer.borderWidth = 0.5;
    _result.layer.borderColor = [UIColor lightGrayColor].CGColor;
    radius(_result, 2);
    _result.userInteractionEnabled = YES;
//    _result.alpha = 0.8;

    _result.keyboardType = UIKeyboardTypeNumberPad;
    
    _result.textAlignment = NSTextAlignmentCenter;
    _result.textColor = textcolor;
    _result.font = Countfont(SCREEN_WIDTH*0.042);
    
    [self addSubview:_result];
    [_result mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.centerX.equalTo(self);
        make.height.equalTo(@(H(self)*2/3));
        make.width.equalTo(@(W(self)/3));
        
    }];
    
    _selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_selectBtn setBackgroundImage:[UIImage imageNamed:@"unfold"] forState:UIControlStateNormal];
    [_selectBtn setTitleColor:mainColor forState:UIControlStateNormal];
    
    _result.rightView = _selectBtn;
    _result.rightViewMode = UITextFieldViewModeAlways;
    _selectBtn.frame = CGRectMake(0, 0, (H(self)*2/3)-2, (H(self)*2/3));
    _selectBtn.adjustsImageWhenHighlighted = NO;

    }

-(void)setModel:(SelectAwardListModel *)model{
    _model = model;
    
    self.name.text = _model.extcredit;
    _result.placeholder = [NSString stringWithFormat:@"%@-%@",_model.min,_model.max];
    self.count.text = _model.left;
}
@end